import request from './request'

/**
 * 获取设备列表
 */
export function getDeviceList(params) {
  return request({
    url: '/devices',
    method: 'get',
    params
  })
}

/**
 * 获取设备详情
 */
export function getDeviceDetail(deviceId) {
  return request({
    url: `/devices/${deviceId}`,
    method: 'get'
  })
}

/**
 * 创建设备
 */
export function createDevice(data) {
  return request({
    url: '/devices',
    method: 'post',
    data
  })
}

/**
 * 更新设备
 */
export function updateDevice(deviceId, data) {
  return request({
    url: `/devices/${deviceId}`,
    method: 'put',
    data
  })
}

/**
 * 删除设备
 */
export function deleteDevice(deviceId) {
  return request({
    url: `/devices/${deviceId}`,
    method: 'delete'
  })
}

/**
 * 获取设备统计
 */
export function getDeviceStats() {
  return request({
    url: '/devices/stats',
    method: 'get'
  })
}

/**
 * 获取设备日志
 */
export function getDeviceLogs(deviceId, params) {
  return request({
    url: `/devices/${deviceId}/logs`,
    method: 'get',
    params
  })
}

/**
 * 获取设备心跳历史
 */
export function getDeviceHeartbeats(deviceId, params) {
  return request({
    url: `/devices/${deviceId}/heartbeats`,
    method: 'get',
    params
  })
}

